package comp6231.project.replica.thomas;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class LockClass {

	public static Lock lock_one = new ReentrantLock();
	public static Lock lock_two = new ReentrantLock();
	public static Lock lock_three = new ReentrantLock();
	public static Lock lock_four = new ReentrantLock();
	public static Lock lock_five = new ReentrantLock();


	public LockClass(String itemId) {
		
		if(itemId.equals("1111")){
			lock_one.lock();
		}
		else if(itemId.equals("2222"))
		{
			lock_two.lock();
		}
		else if(itemId.equals("3333")){
			lock_three.lock();
		}
		else if(itemId.equals("4444")){
			lock_four.lock();
		}
		else if(itemId.equals("5555")){
			lock_five.lock();
		}
		else
		{
			System.out.println("No lock are matched");
		}

	}

	public void releaseLock(String itemId) {
		if(itemId.equals("1111")){
			lock_one.unlock();
		}
		else if(itemId.equals("2222"))
		{
			lock_two.unlock();
		}
		else if(itemId.equals("3333")){
			lock_three.unlock();
		}
		else if(itemId.equals("4444")){
			lock_four.unlock();
		}
		else if(itemId.equals("5555")){
			lock_five.unlock();
		}
		else
		{
			System.out.println("No lock are matched");
		}
	}

}


